package com.agua.enturno.util;

import org.joda.time.Duration;
import org.joda.time.Period;

import java.io.IOException;
import java.util.Properties;

public class Configuration {

	private static final String CONFIG_PROPERTIES_PATH = "config.properties";
	
	private static Configuration instance = new Configuration();
	private Properties configurationFile = null;
	
	public static Configuration getInstance() {
		return instance;
	}
	
	private Configuration() {
		
		configurationFile = new Properties();

		try {
			configurationFile.load(getClass().getClassLoader().getResourceAsStream(CONFIG_PROPERTIES_PATH));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public String getProperty(String key) {
		return configurationFile.getProperty(key);
	}
	
	
	/*---------------------------------- Funciones miembro ---------------------------------*/
	
	public Period getAntelacionMaximaParaCreacionDeHorarios() {
		return Period.parse(getProperty("agenda.antelacion.maxima.creacion.horarios"));
	}

	public Duration getDuracionMinimaDeHorarios() {
		return Duration.parse(getProperty("horario.duracion.minima"));
	}
	
	public Duration getDuracionDefectoDeHorarios() {
		return Duration.parse(getProperty("horario.duracion.defecto"));
	}

	/*--------------------------------------------------------------------------------------*/
	
	
}
